package com.example.writting.ui.wordfill.adapters

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.example.writting.databinding.ItemFixedCombinationBinding
import com.example.writting.model.FixedCombination

class FixedCombinationAdapter : RecyclerView.Adapter<FixedCombinationAdapter.ViewHolder>() {
    private var items = listOf<FixedCombination>()

    fun updateItems(newItems: List<FixedCombination>) {
        items = newItems
        notifyDataSetChanged()
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        val binding = ItemFixedCombinationBinding.inflate(
            LayoutInflater.from(parent.context),
            parent,
            false
        )
        return ViewHolder(binding)
    }

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        holder.bind(items[position])
    }

    override fun getItemCount() = items.size

    class ViewHolder(private val binding: ItemFixedCombinationBinding) : RecyclerView.ViewHolder(binding.root) {
        fun bind(item: FixedCombination) {
            binding.textBubble.text = item.text
        }
    }
} 